<?php
/*
 * 进云智能生成平台
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
 */
//用户端登陆
//基本思路：当需要用户登陆方可访问时，跳转至此页。先检测用户环境（微信端、手机端、pc端、小程序端）
//微信端和小程序端统一处理：如果存在$_SESSION['openid']则根据openid来登陆
//微信端如果没能获取到openid，则类比普通手机端处理
//普通手机端和pc端统一处理
//总结精炼：登陆（注册）前不判断，登陆（注册）后，如果session中有openid，则把当前粉丝与登陆的用户绑定
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
$return['account']=$_SESSION['account'];
$return['extradata']=array();
$setting=uni_setting('register');
$_SESSION['isauth_base']=0;
if($_RQ['op']=='get'){
	$return['item']=array();
	$return['title']='注册';
	$item=array();
	$item['show_type']=$setting['login_type']==2?true:false;
	$item['login_type']=$setting['login_type'];
	$return['setting']=$setting;
	$item['xieyi_title']=$setting['xieyi_title'];
	$item['user_xieyi']=$setting['user_xieyi'];
	$item['fromcode']=$_SESSION['uid'];
	$return['item']=$item;
	set_html('title','代注册');
	exi($return);
}
if($_RQ['op']=='register'){
	//注册
	$post=get_postdata();
	$login_type=intval($post['login_type']);
	$login_type=$login_type==2?0:$login_type;
	//账号密码注册
	if(!$post['username']){
			exi('请输入账号！','error');
	}
	if(!$post['password'] || !$post['password2']){
			exi('请输入密码！','error');
	}
	if($post['password'] != $post['password2']){
			exi('两次输入密码不一致！','error');
	}
	$uid=pdo_getcolumn('core_members',array('username'=>$post['username'],'uniacid'=>$_SESSION['uniacid']),'id');
	if($uid){
			exi('账号已存在，请更换!','error');
	}
	$member=array('username'=>trim($post['username']),'password'=>trim($post['password']),'mobile'=>trim($post['mobile']),'realname'=>trim($post['realname']));
	$member['fromcode']=trim($post['fromcode']);
	if($post['check']!=1 && $post['needcheck']){
		exi('请先阅读协议！','error');
	}
	$uid=model('core/member')->register($member,true);
	$insert=array(
		'mid'=>$uid,
		'uniacid'=>$_SESSION['uniacid'],
		'fromuser'=>$_SESSION['uid'],
		'createtime'=>TIMESTAMP,
	);
	pdo_insert('jy_ad_member',$insert);
	exi('代注册成功！','success','goback');
}
?>